package com.tjetc.controller;

import com.tjetc.common.JsonResult;
import com.tjetc.entity.Merchant;
import com.tjetc.service.ImageService;
import com.tjetc.service.MerchantService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user/merchant")
public class MerchantController {
    @Autowired
    MerchantService merchantService;

    @Autowired
    ImageService imageService;

    /***
     * 查询商家信息
     * @param id
     * @return
     */
    @RequestMapping("checkById")
    public JsonResult checkById(@RequestParam("merchantId") Integer id){
        Merchant merchant = merchantService.selectById(id);
        System.out.println(merchant);
        return new JsonResult<>(0, "", merchant);
    }

    /**
     * 获得商家的轮播图
     * @param id 传入的商家id
     * @return 返回轮播图路径数组
     */
    @RequestMapping("getMerchantImage")
    public JsonResult getMerchantImage(@RequestParam("merchantId") Integer id) {
        return imageService.search(id);
    }
}